#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10, M = 2e4 + 10, K = 10, E = 1e5 + 10;
typedef pair<int, int> pi;
struct pred {
  int p, x, t;
  bool operator<(const pred &b) const { return t < b.t; }
};
int tc;
int n, m, k, e, tmax;
int x, y;
int main() {
  cin >> tc;
  while (tc--) {
    cin >> n >> m >> k;
    vector<vector<pi>> adj(n + 1);
    for (int i = 1; i <= m; ++i) {
      int u, v, w;
      cin >> u >> v >> w;
      adj[u].emplace_back(v, w);
      adj[v].emplace_back(u, w);
    }
    cin >> e >> tmax;
    vector<pred> P(e + 1);
    for (int i = 1; i <= e; ++i) {
      int p, x, t;
      cin >> p >> x >> t;
      P.push_back({p, x, t});
    }
    sort(P.begin(), P.end());
    cin >> x >> y;
  }
}
